Skip to content

Fix ColumnDefinitionParser to parse unquoted DEFAULT NULL as SQL NULL - #1202

Merged
vjik merged 4 commits into
yiisoft:masterfrom
Lugat:fix-default-null-definition
Oct 17, 2026
Merged

vjik merged 4 commits into
yiisoft:masterfrom
Lugat:fix-default-null-definition

Conversation

@Lugat

@Lugat Lugat commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

As discussed in yiisoft/db-mysql#485: an unquoted NULL after DEFAULT was stored as defaultValueRaw = 'NULL'. The MySQL ColumnFactory typecasts it by column type, so int DEFAULT NULL was created as DEFAULT 0. This breaks the yiisoft/queue-db migration: messages are never reserved because reserved_at IS NULL never matches.

String defaults are always quoted in a column definition, so an unquoted NULL can only be SQL NULL. It is now parsed as defaultValueRaw = null. Schema reading from information_schema is not affected, so varchar DEFAULT 'NULL' keeps working.

Checked on MySQL 8.0: int DEFAULT NULL → DEFAULT NULL (was DEFAULT 0); int DEFAULT 5 and varchar(10) DEFAULT 'NULL' are unchanged.

Q A
Is bugfix? ✔️
New feature? ❌
Breaks BC? ❌
Fixed issues yiisoft/db-mysql#485

Related PR: yiisoft/db-mysql#488

String defaults are always quoted in a column definition, so an unquoted
NULL can only be SQL NULL. Previously it was stored as defaultValueRaw
'NULL' and the MySQL column factory typecast it to 0 for integer columns
(e.g. 'int DEFAULT NULL' was created as DEFAULT 0).

See yiisoft/db-mysql#485
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.73%. Comparing base (301c497) to head (c8cf058).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1202   +/-   ##
=========================================
  Coverage     98.73%   98.73%           
- Complexity     1661     1663    +2     
=========================================
  Files           125      125           
  Lines          4340     4342    +2     
=========================================
+ Hits           4285     4287    +2     
  Misses           55       55           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread CHANGELOG.md Outdated
@vjik
vjik requested a review from a team October 1, 2026 09:22
@vjik vjik added the status:code review The pull request needs review. label Oct 1, 2026

@Tigrov Tigrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread src/Syntax/ColumnDefinitionParser.php Outdated
Tigrov and others added 2 commits October 6, 2026 09:04
Co-authored-by: Sergei Predvoditelev <sergey.predvoditelev@gmail.com>
Co-authored-by: Sergei Tigrov <rrr-r@ya.ru>
@vjik
vjik merged commit 6c56b69 into yiisoft:master Oct 17, 2026
82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:code review The pull request needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants